package br.com.processo.persistencia;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;

import br.com.processo.modelo.Processo;
import br.com.processo.persistencia.dao.GenericDAOImpl;

public class ProcessoDAO extends GenericDAOImpl<Processo> implements Serializable {

	private static final long serialVersionUID = 8011506021340678183L;

	public List<Processo> listarProcessosPorSetor(Long idSetor) {
		String sql = "SELECT p FROM Processo p WHERE p.setor.id = :setor";
		TypedQuery<Processo> query = this.entityManager.createQuery(sql, Processo.class);
		query.setParameter("setor", idSetor);
		try {
			return query.getResultList();
		} catch (NoResultException ex) {
			return new ArrayList<Processo>();
		}
	}

}
